package com.fzh.bookstore.biz.order.controller;

import com.fzh.bookstore.biz.order.dto.*;
import com.fzh.bookstore.biz.order.service.OrderService;
import com.fzh.bookstore.dto.SuperResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author fang
 * @since 2021-02-25
 */
@RestController
@RequestMapping("/order")
@Api(value = "订单模块",tags = {"订单模块"})
public class OrderController {

    @Autowired
    private OrderService orderService;


    @PostMapping("/paymeny")
    @ApiOperation(value = "付款（APP）" ,notes = "")
    public SuperResponse payment(@Valid @RequestBody PaymentRequest request ){
        return  orderService.payment(request);
    }


    @PostMapping("/create")
    @ApiOperation(value = "创建订单（APP）" ,notes = "")
    public SuperResponse list(@Valid @RequestBody OrderCreateRequest request ){
        return  orderService.createOrder(request);
    }

    @PostMapping("/addCart")
    @ApiOperation(value = "加入购物车（APP）" ,notes = "")
    public SuperResponse addCart(@Valid @RequestBody CartAddRequest request ){
        return  orderService.addCart(request);
    }


    @PostMapping("/orderList")
    @ApiOperation(value = "订单列表（APP）" ,notes = "")
    public SuperResponse orderList(@Valid @RequestBody OrderListRequest request ){
        return  orderService.orderList(request);
    }


    @PostMapping("/info")
    @ApiOperation(value = "订单详情（APP）" ,notes = "")
    public SuperResponse info(@Valid @RequestBody OrderInfoRequest request ){
        return  orderService.orderInfo(request);
    }

}

